﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using ChGK.Data;

namespace CHGK.web.UI.Core.Providers
{
    public class CHGKRoleProvider: RoleProvider
    {
        DataManager _DataManager = new DataManager();

        public override bool RoleExists(string roleName)
        {
            return _DataManager.Users.IsRoleExist(roleName);
        }

        public override bool IsUserInRole(string username, string roleName)
        {
            if (_DataManager.Users.GetRoleByLogin(username) == roleName)
            {
                return true;
            }

            return false;
        }

        public override string[] GetRolesForUser(string username)
        {
            string[] _Role = {_DataManager.Users.GetRoleByLogin(username)};

            return _Role;
        }

        public override string[] GetAllRoles()
        {
            string[] _AllRoles = { "User", "Superuser" };
            return _AllRoles;
        }

        public override string ApplicationName
        {
            get
            {
                return "ChGKWebSuite";
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            throw new NotImplementedException();
        }

        public override string[] GetUsersInRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            throw new NotImplementedException();
        }

        public override void CreateRole(string roleName)
        {
            throw new NotImplementedException();
        }


    }
}